import { getAllOption } from '@/api/util';

const getDefaultState = () => {
    return {
        options: {}
    };
};

const state = getDefaultState();

const mutations = {
    SET_OPTIONS: (state, options) => {
        state.options = options;
    }
};

const actions = {
    options ({commit}) {
        return new Promise((resolve, reject) => {
            getAllOption().then(response => {
                const {data} = response;
                
                commit('SET_OPTIONS', data);
                resolve();
            }).catch(error => {
                reject(error);
            });
        });
    }
};

export default {
    namespaced: true,
    state,
    mutations,
    actions
};

